/*******************************************************************************
 * Copyright (c) 2011 Prometheus Consulting
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/

package nz.co.senanque.vaadinsupport.viewmanager;

import java.util.HashMap;
import java.util.List;

import com.vaadin.Application;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Window;

public interface ViewManager
{

    /**
     * Combine pushing a new view with adding (put) a view.
     * @param viewName
     * @param newView
     */
    public abstract void pushScreen(String viewName, ComponentContainer newView);

    /**
     * Load the named view but push it onto the internal list.
     * Later you can call popScreen to get back.
     * @param viewName
     */
    public abstract void pushScreen(String viewName);

    /**
     * Switches back to the topmost screen in the screen stack.
     */
    public abstract void popScreen();

    public abstract Panel getWindow();

    public abstract void put(String name, ComponentContainer layout);

    public abstract ComponentContainer get(String name);

    public abstract HashMap<String, ComponentContainer> getViews();

    public abstract Window getMainWindow();

    /**
     * Load the application layouts and switch to the first one found.
     * Normally this is called after login.
     */
    public abstract void loadApplication();

    /**
     * Calls the application to logout
     */
    public abstract void logout();

    /**
     * The initial layouts are loaded before we login so they usually consist of just the login page and maybe the help page.
     * @return
     */
    public abstract List<ViewManaged> getInitialLayouts();

    /**
     * The application layouts are loaded after the login has happened.
     * @return
     */
    public abstract List<ViewManaged> getApplicationLayouts();

    /**
     * Switch to the requested layout
     * 
     * @param name
     */
    public abstract void switchScreen(String name);
    public void setApplication(Application application);

	public abstract Application getApplication();


}